// #ifndef VUE3
import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false

// 按需导入 $http 对象
import {
	$http
} from '@escook/request-miniprogram'

// 在 uni-app 项目中，可以把 $http 挂载到 uni 顶级对象之上，方便全局调用
uni.$http = $http
$http.baseUrl = 'https://api-hmugo-web.itheima.net'
$http.beforeRequest = function(options) {
	uni.showToast({
		title: "数据加载中……",
		icon: "loading"
	})
	if (options.url.indexOf('/my/') != -1) {
		options.header.Authorization = 'Bearer eyJhbGciOiJIUzl1NilsInR5cCl6lkpXVCJ9.eyJ1aWQiOjM1LCJpYXQV4cCI6MTAwMTU5ODg2NjQ1MX0.8hg6C7spbNrs87YECTLzPqGJZ1Ho39Su8r6D3KOTzUE'
	}
}
$http.afterRequest = function() {
	uni.hideLoading()
}

uni.$showMsg = function(title = "数据请求失败！", icon = "none") {
	return uni.showToast({
		title: title,
		icon: icon
	})

}
App.mpType = 'app'
import store from './store'
const app = new Vue({
	...App,
	store
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
import App from './App.vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif